var _util = require('util/util.js');

var _order_servcie = {

    myOders: function (username,resolve, reject) {
        _util.request({
            //后端的url
            url: _util.getServerURL('order/user/'+ username + '/orders'),
            method: "GET",
            success: resolve,
            error: reject,
        });
    },
    viewOders: function (orderId,resolve, reject) {
        _util.request({
            //后端的url
            url: _util.getServerURL('order/user/orders/'+ orderId ),
            method: "GET",
            success: resolve,
            error: reject,
        });
    },
    createOrder: function (account, resolve, reject) {
            _util.request({
            //后端的url
            url: _util.getServerURL('order/newOrder/'+account),
            method  : 'GET',
            //data    : account,
            success : resolve,
            error   : reject
        });
    },
    confirmOrder: function (account, resolve, reject) {
            _util.request({
            //后端的url
            url: _util.getServerURL('order/confirmOrder'),
            method  : 'POST',
            data    : account,
            success : resolve,
            error   : reject
        });
    },
    confOrder : function (resolve, reject) {
            _util.request({
            //后端的url
            url: _util.getServerURL('order/confOrder'),
            method  : 'GET',
            success : resolve,
            error   : reject
        });
    },
    paidOrder : function (resolve, reject) {
        _util.request({
        //后端的url
        url: _util.getServerURL('order/pay/status'),
        method  : 'PATCH',
        success : resolve,
        error   : reject
    });
}
}


module.exports = _order_servcie;